<?php

namespace common\models\shop;

use Yii;

/**
 * This is the model class for table "{{%shop_category_product}}".
 *
 * @property int $id
 * @property string $category_id 栏目ID
 * @property string $product_id 商品ID
 */
class ShopProductCategory extends \common\db\ActiveRecord {

    /**
     * {@inheritdoc}
     */
    public static function tableName() {
        return '{{%shop_product_category}}';
    }

    /**
     * {@inheritdoc}
     */
    public function rules() {
        return [
            [['category_id', 'product_id'], 'integer'],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels() {
        return [
            'id' => 'ID',
            'category_id' => '栏目ID',
            'product_id' => '商品ID',
        ];
    }

    public function getProducts() {
        return $this->hasMany(ShopProduct::className(), ['id' => 'product_id']);
    }

}
